﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Kawanon.Localization;

namespace Kawanon.QtHoney
{
	public partial class PropertiesForm : Form
	{
		[DllImport("user32.dll", CharSet = CharSet.Auto)]
		extern static bool DestroyIcon(IntPtr handle);

		public PropertiesForm()
		{
			InitializeComponent();

			propertyGrid1.ContextMenuStrip = Utility.CreateContextMenuStrip(propertyGrid1);

			StringResource.Apply(MessageBoxButtons.OKCancel, button1, button2);
		}

		public PropertyGrid PropertyGrid
		{
			get
			{
				return propertyGrid1;
			}
		}

		public object SelectedObject
		{
			get
			{
				return propertyGrid1.SelectedObject;
			}
			set
			{
				propertyGrid1.SelectedObject = value;
			}
		}

		public void SetIcon(Bitmap bitmap)
		{
			Icon ico = Icon.FromHandle(bitmap.GetHicon());
			Icon = (Icon)ico.Clone();
			ShowIcon = true;

			DestroyIcon(ico.Handle);
		}
	}
}
